//
//  NetSession.h
//  FreeNet
//
//  Created by cc on 12-7-5.
//  Copyright (c) 2012年 cc. All rights reserved.
//

#ifndef _FREENET_NETSESSION_H_CC_
#define _FREENET_NETSESSION_H_CC_

#include "NetDefine.h"
#include "NetUtil.h"

namespace FreeNet {

#if defined (__SERVER__)
    extern int createTCPServer(const char* ip, const int port, NET_CALLBACK cb) ;
    extern int destroyTCPServer(const int fd, NET_CALLBACK cb) ;
#if defined (__LINUX__)
    extern int createEpollServer(const char* ip, const int port, const eNetMode mode, const int max, NET_CALLBACK cb) ;
    extern int destroyEpollServer(const int fd, NET_CALLBACK cb) ;
#elif defined (__MACOSX__)
    extern int createPollServer(const char* ip, const int port, const eNetMode mode, const int max, NET_CALLBACK cb) ;
    extern int destroyPollServer(const int fd, NET_CALLBACK cb) ;
#endif
    extern int disconnectClient(int fd, NET_CALLBACK cb) ;
#endif

    extern int connectServer(const char* ip, const int port, const eNetMode mode, NET_CALLBACK cb) ;
    extern int disconnectServer(const int fd, NET_CALLBACK cb) ;
    extern size_t sendMessage(const void* data, const int len, const int fd, NET_CALLBACK cb) ;
    extern size_t recvMessage(void* &data, size_t& len, const int fd, NET_CALLBACK cb) ;
    extern size_t sendMessageTo(const char* ip, const int port, const void* data, const int len, NET_CALLBACK cb) ;
    extern size_t recvMessageFrom(const char* ip, const int port, void* &data, size_t& len, NET_CALLBACK cb) ;

#if defined(__USEP2P__)
    extern int requestHole(const char* ip, const int port, NET_CALLBACK cb) ;
#endif

}

#endif

























